package com.lanou.bookstore.category.service;

import com.lanou.bookstore.category.dao.CategoryDao;
import com.lanou.bookstore.category.domain.Category;

import java.sql.SQLException;
import java.util.List;

public class CategoryService {
    private CategoryDao categoryDao = new CategoryDao();

    public List<Category> findAll() {
        List<Category> categoryList = null;
        try {
            categoryList = categoryDao.findAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return categoryList;
    }

    public void add(String cname) {
        try {
            categoryDao.add(cname);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void deleteByCid(String cid) {
        try {
            categoryDao.deleteByCid(cid);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void modifyByCid(String cid, String modCname) {
        try {
            categoryDao.modifyByCid(cid, modCname);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
